package cc.vv.baselibrary.view;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.widget.LinearLayout;


/**
 * 自定义RecyclerView
 * 
 * @author 
 *
 */
public class BCNoScrollRecyclerView extends RecyclerView {

	public BCNoScrollRecyclerView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		//解决scrollview与recylerview嵌套滑动冲突问题
		this.setLayoutManager(new LinearLayoutManager(context, LinearLayout.VERTICAL, false){
			@Override
			public boolean canScrollVertically() {
				return false;
			}
		});
	}

	public BCNoScrollRecyclerView(Context context, AttributeSet attrs) {
		this(context, attrs,-1);
	}

	public BCNoScrollRecyclerView(Context context) {
		this(context, null);
	}



	@Override
	/**
	 * 设置RecyclerView高度使其适应ScrollView
	 */
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
		super.onMeasure(widthMeasureSpec, expandSpec);
	}

}
